/* Smart device Example

   For other examples please check:
   https://github.com/espressif/esp-iot-solution/tree/master/examples

   This example code is in the Public Domain (or CC0 licensed, at your option.)

   Unless required by applicable law or agreed to in writing, this
   software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
   CONDITIONS OF ANY KIND, either express or implied.
 */

#ifndef _IOT_LIGHT_CONFIG_H_
#define _IOT_LIGHT_CONFIG_H_
#include "sdkconfig.h"

#ifdef __cplusplus
extern "C" {
#endif

#if CONFIG_SMART_LIGHT_DEVICE
#define IOT_LIGHT_NAME_SPACE          CONFIG_SMART_LIGHT_NAME_SPACE
#define IOT_LIGHT_PARAM_KEY           CONFIG_SMART_LIGHT_PARAM_KEY
#define IOT_LIGHT_FREQ_HZ             CONFIG_SMART_LIGHT_PWM_FREQ_HZ
#define IOT_LIGHT_PWM_BIT_NUM         CONFIG_SMART_LIGHT_PWM_BIT_NUM
#define IOT_LIGHT_PWM_TIMER_IDX       CONFIG_SMART_LIGHT_PWM_TIMER_IDX
#define IOT_LIGHT_PWM_SPEED_MODE      CONFIG_SMART_LIGHT_PWM_SPEED_MODE
#define IOT_LIGHT_CHANNEL_NUM         CONFIG_SMART_LIGHT_PWM_CHANNEL_NUM

#define IOT_LIGHT_PWM_U0_LEDC_CHANNEL CONFIG_SMART_LIGHT_PWM_UNIT0_LEDC_CHANNEL
#define IOT_LIGHT_PWM_U0_LEDC_IO      CONFIG_SMART_LIGHT_PWM_UNIT0_LEDC_IO
#if IOT_LIGHT_CHANNEL_NUM > 1
#define IOT_LIGHT_PWM_U1_LEDC_CHANNEL CONFIG_SMART_LIGHT_PWM_UNIT1_LEDC_CHANNEL
#define IOT_LIGHT_PWM_U1_LEDC_IO      CONFIG_SMART_LIGHT_PWM_UNIT1_LEDC_IO
#endif
#if IOT_LIGHT_CHANNEL_NUM > 2
#define IOT_LIGHT_PWM_U2_LEDC_CHANNEL CONFIG_SMART_LIGHT_PWM_UNIT2_LEDC_CHANNEL
#define IOT_LIGHT_PWM_U2_LEDC_IO      CONFIG_SMART_LIGHT_PWM_UNIT2_LEDC_IO
#endif
#if IOT_LIGHT_CHANNEL_NUM > 3
#define IOT_LIGHT_PWM_U3_LEDC_CHANNEL CONFIG_SMART_LIGHT_PWM_UNIT3_LEDC_CHANNEL
#define IOT_LIGHT_PWM_U3_LEDC_IO      CONFIG_SMART_LIGHT_PWM_UNIT3_LEDC_IO
#endif
#if IOT_LIGHT_CHANNEL_NUM > 4
#define IOT_LIGHT_PWM_U4_LEDC_CHANNEL CONFIG_SMART_LIGHT_PWM_UNIT4_LEDC_CHANNEL
#define IOT_LIGHT_PWM_U4_LEDC_IO      CONFIG_SMART_LIGHT_PWM_UNIT4_LEDC_IO
#endif

#else
#define IOT_LIGHT_NAME_SPACE          "light"
#define IOT_LIGHT_PARAM_KEY           "light_param"
#define IOT_LIGHT_FREQ_HZ             (1000)
#define IOT_LIGHT_PWM_BIT_NUM         LEDC_TIMER_13_BIT
#define IOT_LIGHT_PWM_TIMER_IDX       LEDC_TIMER_0

#define IOT_LIGHT_PWM_SPEED_MODE      LEDC_HIGH_SPEED_MODE
#define IOT_LIGHT_CHANNEL_NUM         (3)
#define IOT_LIGHT_PWM_U0_LEDC_CHANNEL (0)
#define IOT_LIGHT_PWM_U0_LEDC_IO      (17)
#if IOT_LIGHT_CHANNEL_NUM > 1
#define IOT_LIGHT_PWM_U1_LEDC_CHANNEL (1)
#define IOT_LIGHT_PWM_U1_LEDC_IO      (18)
#endif
#if IOT_LIGHT_CHANNEL_NUM > 2
#define IOT_LIGHT_PWM_U2_LEDC_CHANNEL (2)
#define IOT_LIGHT_PWM_U2_LEDC_IO      (19)
#endif
#if IOT_LIGHT_CHANNEL_NUM > 3
#define IOT_LIGHT_PWM_U3_LEDC_CHANNEL (3)
#define IOT_LIGHT_PWM_U3_LEDC_IO      (20)
#endif
#if IOT_LIGHT_CHANNEL_NUM > 4
#define IOT_LIGHT_PWM_U4_LEDC_CHANNEL (4)
#define IOT_LIGHT_PWM_U4_LEDC_IO      (21)
#endif
#endif

#define LIGHT_FULL_DUTY ((1 << IOT_LIGHT_PWM_BIT_NUM) - 1)

#define IOT_CHANNEL_ID_R    0
#define IOT_CHANNEL_ID_G    1
#define IOT_CHANNEL_ID_B    2
#define IOT_CHANNEL_ID_CW   3
#define IOT_CHANNEL_ID_WW   4

#ifdef __cplusplus
}
#endif

#endif


